﻿#region  文件信息

// ---------------------------------------------------------------------------------------
// <copyright file="AliWapService.cs" company="">
// 作者：李帅伦
// </copyright>
// <summary>
// 类型简介：
// 类型详细：AliWapService.cs
// 创建时间：2015-01-07 18:43
// 修改时间：2015-01-07 18:10
// </summary>
// ---------------------------------------------------------------------------------------
#endregion

namespace Payment.Albaba.WapCode
{
    #region

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;

    using Payment.Albaba.Com;
    using Payment.Albaba.PcCode;

    #endregion

    /// <summary>
    ///     业务服务
    /// </summary>
    public class AliWapService
    {
        // 支付宝网关地址 固定

        // 商户订单号
        #region Fields

        /// <summary>
        /// The Service.
        /// </summary>
        public IPayOrder Order;

        /// <summary>
        /// The config.
        /// </summary>
        private readonly AliConfig config;

        /// <summary>
        /// 订单号
        /// </summary>
        private readonly string outTradeNo;
          
        /// <summary>
        /// 订单名称
        /// </summary>
        private readonly string subject;

        /// <summary>
        /// 付款金额
        /// </summary>
        private readonly string totalFee;
         

        // 服务器异步通知页面路径

        /// <summary>
        /// 页面跳转同步通知页面路径
        /// </summary>
        public string CallBackUrl { get; set; }

        /// <summary>
        /// 操作中断返回地址
        /// </summary>
        public string MerchantUrl { get; set; }

        /// <summary>
        /// 通知url
        /// </summary>
        public string NotifyUrl { get; set; }

        /// <summary>
        /// The seller_email.
        /// </summary>
        private readonly string sellerEmail;
         

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="AliWapService"/> class.
        /// </summary>
        /// <param name="order">
        /// The Service.
        /// </param>
        /// <param name="seller">
        /// </param>
        public AliWapService(IPayOrder order, AliSeller seller)
        { 
            this.outTradeNo = order.GetId();
            this.subject = order.GetSubject();
            this.totalFee = order.GetTotalFee();

            this.sellerEmail = seller.SellerEmail;
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     请求业务参数详细
        /// </summary>
        public string ReqDataToken
        {
            get
            {
                // 请求业务参数详细
                return string.Format("<direct_trade_create_req><notify_url>{0}</notify_url><call_back_url>{1}</call_back_url><seller_account_name>{2}</seller_account_name><out_trade_no>{3}</out_trade_no><subject>{4}</subject><total_fee>{5}</total_fee><merchant_url>{6}</merchant_url></direct_trade_create_req>", this.NotifyUrl, this.CallBackUrl, this.sellerEmail, this.outTradeNo, this.subject, this.totalFee, this.MerchantUrl);
            }
        }

        #endregion



    }
}